package logic

import (
	"context"
	"tieba/api/internal/svc"
	"tieba/api/internal/types"
	"tieba/tiebarpc/tiebarpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type TiZiShowLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewTiZiShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TiZiShowLogic {
	return &TiZiShowLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *TiZiShowLogic) TiZiShow(req *types.TiZiShowRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	show, err := l.svcCtx.TieBaRpc.TiZiShow(l.ctx, &tiebarpc.TiZiShowRequest{TieZiId: int64(req.TieZiId)})
	if err != nil {
		return &types.Response{
			Code:    500,
			Message: err.Error(),
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Code:    200,
		Message: "查看帖子详情成功",
		Data:    show,
	}, nil
	return
}
